import 'package:flutter/material.dart';

class SizedBoxDemo extends StatelessWidget {
  const SizedBoxDemo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Container(
        padding: EdgeInsets.all(16),
        child: Column(children: [
          Container(
            height: 200,
            child: SizedBox.expand(
              child: Container(
                color: Colors.lightBlue,
                child: Center(
                  child: Text(
                    "风沙",
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
            ),
          ),
          Divider(),
          Text("used Expanded+SizedBox.shrink"),
          Row(
            children: [
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
              Expanded(flex: 2, child: SizedBox.shrink()),
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
            ],
          ),
          Divider(),
          Text("used Spacer"),
          Row(
            children: [
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
              Spacer(),
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
            ],
          ),
          Divider(),
          Text("used Row.MainAxisAlignment.spaceBetween"),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
              Container(
                child: Text("嘉年华"),
                color: Colors.green.shade300,
              ),
            ],
          ),
          Divider(),
          SizedBox(
            width: 300,
            height: 150,
            child: Card(
              color: Colors.grey,
              child: Container(
                margin: EdgeInsets.all(16),
                color: Colors.white,
                alignment: Alignment.center,
                child: Text("美好世界"),
              ),
            ),
          ),
        ]),
      ),
    );
  }
}
